package poc;

import org.docx4j.TextUtils;
import org.docx4j.XmlUtils;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.toc.TocHelper;
import org.docx4j.wml.*;
import poc.utils.ParagraphUtil;
import poc.utils.RunUtil;

import javax.xml.bind.JAXBElement;
import java.io.File;
import java.math.BigInteger;
import java.util.List;


public class ToHtml {
	private  static ObjectFactory wmlObjectFactory = new ObjectFactory();

	public static void main(String[] args) throws Exception {
		String newerfilepath = System.getProperty("user.dir") + "/poc_develop/source_1.docx";

		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(newerfilepath));
		List<Object> paragraphs = TocHelper.getAllElementsFromObject(wordMLPackage.getMainDocumentPart(), P.class);

		for (Object p : paragraphs) {
			List<Object> runs= TocHelper.getAllElementsFromObject(p, R.class);
			toHtml(runs);
		}

		String filename = System.getProperty("user.dir") +  "/poc_develop/result_1.docx";
		wordMLPackage.save(new File(filename) );
	}

	/**
	 *
	 * @param runs R 的列表
	 * @return
	 */
	private static String toHtml(List<Object> runs){
		String result= "";


		System.out.println("result:"+result);
		return result;
	}
}


